public class BinaryTree {


     static class TreeNode {
        private char val;
        private TreeNode left;
        private TreeNode right;

        public TreeNode(char val) {
            this.val = val;
        }
    }

    public TreeNode createTree() {
        TreeNode A = new TreeNode('A');
        TreeNode B = new TreeNode('B');
        TreeNode C = new TreeNode('C');
        TreeNode D = new TreeNode('D');
        TreeNode E = new TreeNode('E');
        TreeNode F = new TreeNode('F');
        TreeNode G = new TreeNode('G');
        TreeNode H = new TreeNode('H');

        A.left = B;
        B.left = D;
        B.right = E;
        E.right = H;
        A.right = C;
        C.left = F;
        C.right = G;
        return A;
    }
    public boolean isSymmetricTree(TreeNode rootL,TreeNode rootR) {
        if(rootL == null && rootR != null) return false;
        if(rootL != null && rootR == null) return false;
        if(rootL == null && rootR == null) return true;

        if(rootL.val != rootR.val) {
            return false;
        }

        return isSymmetricTree(rootL.left,rootR.right) && isSymmetricTree(rootL.right,rootR.left);
    }
    public boolean isSymmetric(TreeNode root) {
        if(root == null) return true;

        return isSymmetricTree(root.left,root.right);

    }
}